package com.example.dao;

import com.example.common.DataStatus;
import com.example.common.WorkType;
import com.example.entity.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sky.entity.Employee;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserMapper {
//
////    @Query(value = "select * from user where name like %?1%", nativeQuery = true)
////    Page<User> findByNameLike(String name, Pageable pageRequest);
        List<Recording> getbymatchcriteria(matchCriteria criteria);

        @Select("SELECT * FROM orders")
        List<Order> getOrder();

        @Select("SELECT * FROM orders WHERE id=#{id}")
        Order getOneOrder(Long id);

        @Insert("insert into vehicle_weight_records (weighbridge_name, license_plate, work_type, material_name, material_specification, material_units, weight, weighing_time, remarks, data_status, order_id) " +
                "values" +
                "(#{weighbridgeName},#{licensePlate},#{workType},#{materialName},#{materialSpecification},#{materialUnits},#{weight},#{weighingTime},#{remarks},#{dataStatus},#{orderID})")
        @Options(useGeneratedKeys = true, keyProperty = "id")
        Long insertVehicle(vehicle_weight_record records);



        void invalid(Long id);
        @Select("SELECT id FROM vehicle_weight_records WHERE license_plate = #{licensePlate} and weighing_time = #{heavyweighingTime}")
//        @Select("SELECT id FROM vehicle_weight_records WHERE license_plate = #{licensePlate}")
        Long SearchV(String licensePlate, Date heavyweighingTime);

        @Insert("insert into null_weight_records (weighbridge_name, license_plate, work_type, weight, weighing_time, gross_weight_id, data_status) " +
                "values" +
                "(#{weighbridgeName},#{licensePlate},#{workType},#{weight},#{weighingTime},#{grossWeightId},#{dataStatus})")
        @Options(useGeneratedKeys = true, keyProperty = "id")
        Long insertN(nullWeightRecord record);

        @Select("SELECT order_id FROM vehicle_weight_records WHERE id=#{id}")
        Long VSearchOrder(Long id);

        @Select("SELECT remarks FROM vehicle_weight_records WHERE id=#{id}")
        String VSearchremark(Long id);

        @Update("UPDATE orders SET received_weight = #{weight} where id = #{id}")
        void insertReceived_weight(Long id, Integer weight);


        @Insert("insert into order_details(license_plate, order_name, delivery_type, supplier_name, material_name, material_spec, material_unit, remark, received_quantity, theoretical_weight, actual_weight) " +
                "values" +
                "(#{licensPlate},#{orderName},#{deliveryType},#{supplierName},#{materialName},#{materialSpec},#{materialUnit},#{remark},#{receivedQuantity},#{theoreticalWeight},#{actualWeight})")
        void insertOrder_details(orderRecord details);
}
